import request from '@/utils/adminRequest'

//管理员登录
export const adminLoginService = ({ studentId, password }) =>
  request.post('/admin/login', { username: studentId, password })
//-----------教师基本信息管理--------------
//添加教师基本信息
export const addTeacherInfoService = ({ id, name, jobTitle, salary }) =>
  request.put('/teacher/addTeacher', { id, name, jobTitle, salary })

//删除教师基本信息
export const deleteTeacherInfoService = (teacherId) =>
  request.delete(`/teacher/deleteTeacher/${teacherId}`)

//统计不同职称的教师的数量、不同职称的教师的平均工资
export const getTeacherTotalService = () =>
  request.get(`/teacher/statistics`)

//修改教师基本信息
export const updateTeacherInfoService = ({ id, name, jobTitle, salary }) =>
  request.post('/teacher/updateTeacher', { id, name, jobTitle, salary })

//展示教师基本信息
export const getAllTeacherInfoService = () =>
  request.get('/teacher/getAllTeacher')

//-----------课程基本信息管理--------------
//添加课程基本信息
export const addCourseInfoService = ({ id, name, credits, teacherId }) =>
  request.put('/course/addCourse', { id, name, credits, teacherId })

//删除课程基本信息
export const deleteCourseInfoService = (courseId) =>
  request.delete(`/course/deleteCourse/${courseId}`)

//展示所有课程
export const getAllCourseInfoService = () =>
  request.get('/course/getAllCourses')

//修改课程基本信息
export const updateCourseInfoService = ({ id, name, credits, teacherId }) =>
  request.post('/course/updateCourse', { id, name, credits, teacherId })

//-----------学生成绩管理--------------
//管理员录入课程成绩
export const addScoreService = ({ studentId, courseId, grade, id }) =>
  request.put('/enrollment/addEnrollment', { studentId, courseId, grade, id })

//展示所有学生成绩
export const getAllScoreService = ({ courseId, pageNo, pageSize }) =>
  request.get(`/enrollment/getEnrollment?courseId=${courseId}&pageNo=${pageNo}&pageSize=${pageSize}`)

//统计每个学生选修课程的总学分
export const getCreditService = () =>
  request.get(`/enrollment/getCreditByStudent`)

//统计每门课程的平均成绩、最高分、最低分
export const getEnrollmentService = () =>
  request.get(`/enrollment/getEnrollmentStatistics`)

//-----------学生基本信息管理--------------
//展示所有学生基本信息
export const getAllStudentInfoService = () =>
  request.get(`/admin/getAllStudents`)

//添加学生基本信息
export const addStudentInfoService = ({ name, gender, age, studentId }) =>
  request.put('/admin/addStudent', { name, gender, age, studentId })

//根据学生ids集合删除学生基本信息
export const deleteStudentInfoService = (ids) =>
  request.delete(`/admin/deleteStudentByIds?ids=${ids}`)

//更新学生基本信息
export const updateStudentInfoService = ({ id, name, gender, age, studentId, password }) =>
  request.post('/admin/updateStudent', { id, name, gender, age, studentId, password })
